<link rel="stylesheet" type="text/css" href="{$atplPath}skin/house_pingtai.css" />
<style>
.pline {}
.pline em { font-weight:normal; font-style:normal; color:#36c; padding-right:12px;}
.pline .success { color:#5cc55c;}
.pline .error { color:#d00;}
</style>
<div class="wrapper_house clearfix" id="app">
	<div class="inner_sub_box">
		<div class="hd">极速批量添加小区<span class="small_font">帮您快速建立起本地小区数据库</span></div>
			<ul class="ul-form clearfix">
				
				<li>
					<span class="txt">添加到：</span>
					<div class="con">
						<input type="hidden" name="Quyuid" id="Quyuid" v-model="Quyuid" />
						<input type="hidden" name="Diduanid" id="Diduanid" v-model="Diduanid" />
						<div class="sel_box" @mouseenter="QuyuidShow=true" @mouseleave="QuyuidShow=false">{{QuyuidName}}<i class="ico"></i>
							<div class="sel_po" v-show="!!QuyuidShow">
								<item-select v-for="tag in QuyuidList" :key="tag.Categoryid" :tag="tag" forid="Quyuid" fortxt="QuyuidName" fotaction="QuyuidShow" is2="Diduanid"></item-select>
							</div>
						</div><div class="sel_box" @mouseenter="if(DiduanidList.length!='0') DiduanidShow=true" @mouseleave="DiduanidShow=false">{{DiduanidName}}<i class="ico"></i>
							<div class="sel_po" v-show="!!DiduanidShow">
								<item-select v-for="tag in DiduanidList" :key="tag.Categoryid" :tag="tag" forid="Diduanid" fortxt="DiduanidName" fotaction="DiduanidShow" is2=""></item-select>
							</div>
						</div>
					</div>
				</li>
				<li>
					<span class="txt">添加到：</span>
					<div class="con">
						<table cellpadding="10" cellspacing="0" border="0" width="100%;">
							<tr>
								<td width="50%"><textarea placeholder="一行一个" class="int inp-form-sz inp-form-textarea" v-model="content" style="width: 100%; height: 200px;"></textarea></td>
								<td width="50%"><div class="int inp-form-sz inp-form-textarea" style=" display:block; height: 200px;" id="append_inner"></div></td>
							</tr>
						</table>
						
						<span class="zhu1 zhu2">一行一个小区名称，按照区域地段批量添加；添加完成后请在管理列表完善资料！</span>
					</div>
				</li>
			</ul>
			<input type="button" @click="submitHandle()" value="确认提交" class="btn-form ani">
		
	</div>
 
</div>

<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak={$ggmapkey}"></script>
<script type="text/javascript" src="//developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<script src="{$atplPath}js/jquery-1.10.2.min.js"></script>
<script src="{$atplPath}js/purl.js"></script>
<script src="{$atplPath}js/vue/axios.min.js"></script>
<script src="{$atplPath}js/vue/es6-promise.auto.min.js"></script>
<script src="{$atplPath}js/vue/vue.min.js"></script>
<script src="{$atplPath}js/vue/houseCategory.js"></script>
<script src="{$atplPath}js/vue/form_2018.js"></script>

<script>
window['CITY'] = '{$city}';
var mypage = new Vue({
	el: '#app',
	components: {
		'item-select':Item_select
	},
	data: {
		content:'',
		QuyuidShow:false,
		Quyuid:'0',
		QuyuidName:'请选择区域',
		QuyuidList:[],
		DiduanidShow:false,
		Diduanid:'0',
		DiduanidName:'请选择地段(可不选)',
		DiduanidList:[],
		Loupan_x:0,
		Loupan_y:0,
		Loupan_z:0,
		ChrloupanArr:[]
	},
	methods:{
		getTagData:function(styleid,sid,forname){
			var that = this,url='';
			if(styleid === '0'){
				url = '/api/HouseCategory/SearchHouseCategory';
				$.ajax({'url':url,dataType:'json',data:{'Category':sid,'timer':Math.random()},success:function(data){
					
				}});
			}else{
				url = '/api/Category/SearchCategory';
				$.ajax({'url':url,dataType:'json',data:{'Category':sid,'timer':Math.random()},success:function(data){
					var i=0,len=data[sid].length,arr=[];
					if(that[forname]!==''){
						arr = that[forname];
					}
					for(;i<len;i++){
						for(var k = 0;k<arr.length;k++){
							if(arr[k] == data[sid][i].Categoryid){
								data[sid][i].checked=true;
							}
						}
						that[forname+'List'].push(data[sid][i]);
					}
				}});
			}
		},
		setmobileSelect:function(){
			var that=this;
			getHouseCatJSON('1','0','Quyuid',setQuyuSel_vue);
		},
		addXiaoqu:function(obj){
			var that = this,url = '/api/XiaoQu/XiaoQuAdminSubbmit',append_inner = $('#append_inner');
			var Chrloupan = that.ChrloupanArr.shift();
			
			var obj = {
				Quyuid:that.Quyuid,
				Diduanid:that.Diduanid,
				Chrloupan:Chrloupan
			};
			
			$.ajax({
				url:url,
				type:"POST",
				dataType:"json",
				contentType:"application/json;charset=utf-8",
				data: JSON.stringify(obj),
				success:function(res){
					var txt = '';
					if(typeof res.iserror !== 'undefined' && res.iserror === 1){
						append_inner.append('<div class="pline"><em class="error">'+obj.Chrloupan+'</em>添加失败了！可能已有同名小区了！</div>');
					}else{
						append_inner.append('<div class="pline"><em>'+obj.Chrloupan+'</em>添加成功！</div>');
					}
					if(that.ChrloupanArr.length > 0){
						that.addXiaoqu();
					}else{
						that.content = '';
						append_inner.append('<div class="pline"><em class="success">队列完成了！</em></div>');
					}
				},
				error:function(message){  
					MSGwindowShow('house','0','操作失败了！','','');
				}
			});
		},
		submitHandle:function(){
			var that = this;
			if(that.Quyuid === "0") {
				MSGwindowShow('house','0','请输入选择区域地段！','','');
			}else if(that.content === ""){
				MSGwindowShow('house','0','请输入小区名称！','','');
			}else{
				var arr = that.content.split("\n");
				if(arr.length===0){return false;}
				that.ChrloupanArr = arr;
				that.addXiaoqu();
			}
		}
		
	},
	created:function(){
		var that = this;
		that.setmobileSelect();
	},
});

</script>